package com.demo;

import java.util.Scanner;

public class StringDemo6 {
    public static void main(String[] args) {
        //1.键盘录入一个字符串
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入一个字符串：");
        String str = scanner.next();
        //2.统计---计数器思想
        //定义三个计数器
        int big = 0;
        int small = 0;
        int number = 0;
        int other=0;
        for (int i = 0; i < str.length(); i++) {
            //i依次表示字符串的每一个索引
            char c = str.charAt(i);
            if (c >= 'a' && c <= 'z') {
                small++;
            } else if (c >= 'A' && c <= 'Z') {
                big++;
            } else if (c >= '0' && c <= '9') {
                number++;
            }else {
                other++;
            }
        }
        System.out.println("大写字符有："+big+"个");
        System.out.println("小写字符有："+small+"个");
        System.out.println("数字字符有："+number+"个");
        System.out.println("其他字符有："+other+"个");
    }
}
